<?php

namespace JsonLowCode\UI;

use JsonLowCode\Schema;
use JsonLowCode\Traits\Slots\HasSlotSuffix;

/**
 * GridItem组件
 * @method static GridItem make(mixed $children = null, int $span = 1, int $offset = 0) GridItem组件
 */
class GridItem extends Schema
{
    use HasSlotSuffix;

    protected string $componentName = "NGridItem";

    /**
     * @param mixed|null $children
     * @param int $span
     * @param int $offset
     */
    public function __construct(mixed $children = null, int $span = 1, int $offset = 0)
    {
        parent::__construct();
        $offset!=0 && $this->offset($offset);
        $span!=1 && $this->span($span);
        $this->children($children);
    }

    /**
     * 栅格左侧的间隔格数
     * @param int|string $offset
     * @return $this
     */
    public function offset(int|string $offset = 0): static
    {
        return $this->prop('offset', $offset);
    }

    /**
     * 栅格占据的列数，为 0 的时候会隐藏
     * @param int $span
     * @return $this
     */
    public function span(int $span = 1): static
    {
        return $this->prop('span', $span);
    }
}
